An example

Some general remark: The algorithms used relies heavily on optimization. Therefore it is not guranteed that the algorithms will find always a errorfree solution (even when you can spot the errorfree solution).

The Leisepark in Berlin

Part of the package is a data set about portals in the Leisepark in Berlin, Germany (Ingress intel map).

  library("findWeb")
  data(leisepark)
  head(leisepark)
##                                         name             shortname length
## 1 Tombstone Showing A Portal Being Captured    Tombstone Showing …     19
## 2     Grabstätte Familie Schultze und Kramer Grab. Fam. Schultze …     21
## 3             Grabstein Hans-Joachim Wilhelm     Grab. H-J Wilhelm     17
## 4                Ruhestätte Familie Dellscha   Ruhe. Fam. Dellscha     19
## 5                    Hängematte Im Leisepark       Hängematte Im …     15
## 6                    Stolperstein Mendelsohn   Stolper. Mendelsohn     19
##        lat      lon
## 1 52.52955 13.42254
## 2 52.53028 13.42343
## 3 52.52886 13.42308
## 4 52.52963 13.42115
## 5 52.53003 13.42122
## 6 52.53041 13.42391

Step 1: Compute xy portal positions from latitude annd longitude and a web

Convert the latitudes and longitudes to xy-coordinates

  xy <- ll2xy(leisepark$lon, leisepark$lat)
  head(xy)
##             x       y
## [1,] 392992.8 5821108
## [2,] 393054.6 5821188
## [3,] 393027.6 5821031
## [4,] 392898.3 5821119
## [5,] 392903.8 5821163
## [6,] 393087.6 5821201

Next, we will create as target linking structure a fishbone (or herringbone) linking structure.

The fishbone(8) structure consists of nine portals, twentyone links and 19 fields. It was one of the popular linking structures since the EXO5 Controller event in October 2017 since it is simple. And in any case no Softbank Ultra Link is necessary to build it.

What can I do if the program does not find a solution and neither me, too?

There are two parameters you may modify

  • increase the number of iterations in the optimization
  set.seed(0)
  g12 <- optimizeWeb(g0, maxit=1000000) # default: 100000

  • improve the starting position by a finer rotation for the structure
  g02 <- web(g, xy, rot=1024) # default: 256
  plot(g02)

In general the optimization algorithm will honor it if you have more portals available than your target structure requires.

Helpful informations

Plotting

The plot command offers additional parameters which are set on TRUE by default.

plot(g4, blue=FALSE) # do not plot the blue numbers

plot(g4, black=FALSE) # do not plot the black numbers

plot(g4, links=FALSE) # do not plot the links

plot(g4, pathes=FALSE) # do not plot the agent pathes

Using the forward pipe operator

To simplify the typing you may use the forward pipe operator %>% of the library magrittr. Instead of writing

g0 <- fishbone(8)
g1 <- web(g0, xy)
g2 <- optimizeWeb(g1)
g3 <- linkPlan1(g2)
plot(g3, blue=FALSE)

you may use

library("magrittr") # for %>% operator
fishbone(8) %>% web(xy) %>% optimizeWeb() %>% linkPlan1() %>% plot(blue=FALSE)

## [1] -1.198445

Or alternatively

g <- fishbone(8) %>% web(xy) %>% optimizeWeb() %>% linkPlan1()
plot(g, blue=FALSE)

Thanks

Finally, a thanks to Stefan Dirsch for testing the R package, Michael Hartley for his videos and the authors of R package FNN: Fast Nearest Neighbor Search Algorithms and Applications ;)

Enjoy planing and linking, agents!